//
// Created by user on 2022/2/21.
//
#include <vector>
using namespace std;

vector<int> sortArrayByParityII(vector<int>& nums) {
    int n = nums.size();
    vector<int> res(n);
    //偶数
    int index=0;
    for (int i = 0; i < n; ++i) {
        if(nums[i]%2==0){
            res[index]=nums[i];
            index +=2;
        }
    }
    //奇数
    index=1;
    for (int i = 0; i < n; ++i) {
        if(nums[i]%2==1){
            res[index]=nums[i];
            index +=2;
        }
    }
    return res;

}